package mc.support.support.pojo;

import java.io.Serializable;
import java.util.List;

/**
 * Created with IntelliJ IDEA. <br/>
 * Author: francis Yun    <br/>
 * Date: 2013-11-27  <br/>
 */
public class Fragment<T> implements Serializable {

    private static final long serialVersionUID = -4451438412368369516L;
    private List<T> content;
    private Integer totalSize;

    public List<T> getContent() {
        return content;
    }

    public void setContent(List<T> content) {
        this.content = content;
    }

    public Integer getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(Integer totalSize) {
        this.totalSize = totalSize;
    }

    public void generateIndexes(int begin, int offset) {
        if ( begin < 0 || offset < 0 ) {
            return;
        }

        if ( null != content ) {
            int index = begin;
            int len = content.size();
            for ( int i = 0; i < len && i <= offset; i++ ) {
                T t = content.get( i );
                if ( t instanceof IFragElem) {
                    IFragElem elem = (IFragElem) t;
                    elem.setIndex( begin + i );
                } else {
                    break;
                }
            }
        }

    }

}
